package com.zzyl.controller.manager;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.entity.NursingProject;
import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(path = "/nursing_project")
@Api(tags = "护理项目管理")
public class NursingProjectController {

    @Autowired
    private NursingProjectService nursingProjectService;

    /**
     * 分页条件查询
     */
    @GetMapping
    @ApiOperation("分页条件查询")
    public ResponseResult<PageResponse<NursingProjectVo>> queryNursingProject(String name, Integer pageNum, Integer pageSize, Integer status) {
        PageResponse<NursingProjectVo> nursingProject = nursingProjectService.queryNursingProject(name, pageNum, pageSize, status);
        return ResponseResult.success(nursingProject);
    }

    /**
     * 根据id查询护理项目
     */
    @GetMapping(path = "/{id}")
    @ApiOperation("根据id查询护理项目")
    public ResponseResult<NursingProjectVo> getById(@PathVariable Long id) {
        NursingProjectVo nursingProjectVo = nursingProjectService.getById(id);
        return ResponseResult.success(nursingProjectVo);
    }

    /**
     * 修改护理项目详情
     */
    @PutMapping
    @ApiOperation("修改护理项目详情")
    public ResponseResult<Void> modifyNursingProject(@RequestBody NursingProjectDto nursingProjectDto) {
        nursingProjectService.modifyNurxsingProject(nursingProjectDto);
        return ResponseResult.success();
    }

    /**
     * 新增护理项目
     */
    @PostMapping
    @ApiOperation("新增护理项目")
    public ResponseResult<Void> addNursingProject(@RequestBody NursingProjectDto nursingProjectDto){
        nursingProjectService.addNursingProject(nursingProjectDto);
        return ResponseResult.success();
    }

    /**
     *  启用禁用
     */
    @PutMapping(path = "/{id}/status/{status}")
    @ApiOperation("启用禁用")
    public ResponseResult<Void> enableOrDisable(@PathVariable Long id,@PathVariable Integer status){
        nursingProjectService.enableOrDisable(id,status);
        return ResponseResult.success();
    }

    /**
     * 删除护理项目
     */
    @DeleteMapping(path = "/{id}")
    @ApiOperation("删除护理项目")
    public ResponseResult<Void> removeNursingProject(@PathVariable Long id){
        nursingProjectService.removeNursingProject(id);
        return ResponseResult.success();
    }

    /**
     * 查询所有护理项目
     */
    @GetMapping(path = "/all")
    @ApiOperation("查询所有护理项目")
    public ResponseResult<List<NursingProjectVo>> findNursingProjectList(){
        List<NursingProjectVo> list=nursingProjectService.findNursingProjectList();
        return ResponseResult.success(list);
    }
}
